---
title: "# "
output:
flexdashboard::flex_dashboard:
#vertical_layout: fill
orientation: rows
self_contained: true
source: embed
social: menu
bibliography: ../references/references.bib
---
<style>
.navbar {
background-color:green;
border-color:black;
}
.navbar-brand {
color:white!important;
}
</style>
```{r setup, include=FALSE}
packages = c("dplyr", "rgdal", "knitr",
"sf", "viridis", "ggeasy",
"tidyr","scales",
"etasFLP","maptools","sp",
"raster","leaflet","htmlwidgets",
"htmltools", "ggplot2",
"flexdashboard", "tidyverse",
"leaflet.minicharts", "manipulateWidget")
## Now load or install&load all
package.check <- lapply(
packages,
FUN = function(x) {
if (!require(x, character.only = TRUE)) {
install.packages(x, dependencies = TRUE)
library(x, character.only = TRUE)
}
}
)
# Setup knitr
knitr::opts_chunk$set(
echo = FALSE, message = FALSE, warning = FALSE,
# Save all figures in the output dir, you have to include them explicitly
# with an <img> tag
fig.path = "../output/img/", fig.show = "show"
)
```
```{r, include=FALSE}
library(crosstalk)
library(leaflet)
library(dplyr)
library(reactable)
library(kableExtra)
#library(formattable)
#generate all the necessary tables
#setting work directory
pasteo <- "R:/HLSS/Big Data Centre/Data/TRANSFER_FROM_SERVER_ROOM/20221014/GMP/AMO/"
#load all boundary shapefile
#load gm boundary
gm_bdry <- sf::read_sf(paste(pasteo, "boundaries/", "GMP_BOUNDARY_geo", ".shp", sep=""))
#load la boundary
gm_la <- sf::read_sf(paste(pasteo, "boundaries/", "GM_LA_geo", ".shp", sep=""))
#load wards boundary
gm_ward <- sf::read_sf(paste(pasteo, "boundaries/", "gm_ward_geo", ".shp", sep=""))
#load lsoa boundary
gm_lsoa <- sf::read_sf(paste(pasteo, "boundaries/", "GMP_LSOA_BOUNDARY_geo", ".shp", sep=""))
#load city centre boundary
gm_centre <- sf::read_sf(paste(pasteo, "boundaries/", "city_and_town_Centre_merged2", ".shp", sep=""))
```
```{r, include=FALSE}
breweries91 <- leaflet::breweries91
set.seed(1000)
gr <- sample(paste("N", 1:5, sep=""), 32, replace = TRUE)
breweries91_grouped <- cbind(breweries91, data.frame(id=gr))
```
```{r render subpages, include=FALSE}
#prepare data
#-----
#Get all unique offence group names
Offence_group <- unique(breweries91_grouped$id)
#order group
Offence_group <- Offence_group[order(Offence_group)]
#-----
# Create variable which stores all subpages outputs
out = NULL
#-----
# Set knitr options to allow duplicate labels (needed for the subpages)
options(knitr.duplicate.label = 'allow')
# Create temporary environment which we use for knitting subpage.RMD
subpage_env <- new.env()
for (Og in Offence_group) { #Og <- "N1"
# Filter data for product group
subpage_data <- breweries91_grouped[breweries91_grouped$id == Og,]
# Assign filtered data and product group to subpage_env
assign("subpage_data", subpage_data, subpage_env)
assign("Offence_group", Og, subpage_env)
# Knit subpage.RMD using the subpage_env and add result to out vector
out = c(out, knitr::knit_child('subpage.Rmd', envir = subpage_env))
}
```
`r paste(knitr::knit_child(text = out), collapse = '')`
<!-- **References** -->